<?php

namespace App\Http\Controllers\Admin;

use Illuminate\Http\Request;

use App\Models\Comment;

//使用类
use App\Http\Controllers\Controller;

//后台评论控制器
class CommentController extends Controller
{
    //评论首页
    public function index(Request $request){
        //多表查询
        $data=Comment::select("comment.*","goods.title",'goods.img as gimg',"user.name")
            ->join("user","user.id","=","comment.uid")
            ->join("goods","goods.id","=","comment.gid")
            ->get();
        //dd($data);

        //加载页面
        return view("admin.comment.index",[
            "data"=>$data
        ]);

    }

    //ajax修改状态
    public function ajaxStatu(Request $request){

            $arr = $request->except("_token");
            //var_dump($arr);

        $num = Comment::where('id',$request->input('id'))->update($arr);//['statu'=>$request->input('statu')]
        if($num){
            return 1;
        }else{
            return 0;
        }

    }



	
}
